/*******************************************************************************
 * Copyright 2011 Alexandre Zglav and Morphiastic
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.morphiastic.tests.entities.library;

import java.util.HashSet;
import java.util.Set;

import org.bson.types.ObjectId;

import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
import com.google.code.morphia.annotations.Reference;
import com.morphiastic.annotations.ElastiField;
import com.morphiastic.annotations.ElastiFieldEmbedded;
import com.morphiastic.annotations.ElastiMorphed;

@ElastiMorphed(typeName="book")
@Entity("book")
public class Book {

	@Id
	private ObjectId objectId;
	
	@ElastiField
	private String title;
	
	@ElastiField
	private String summary;
	
	@ElastiFieldEmbedded
	@Reference
	private Set<Author> authors;

	
	
	
	
	public void addAuthor(Author author){
		if(authors==null)authors = new HashSet<Author>();
		authors.add(author);
	}
	
	
	

	/**
	 * @return the objectId
	 */
	public ObjectId getObjectId() {
		return objectId;
	}


	/**
	 * @param objectId the objectId to set
	 */
	public void setObjectId(ObjectId objectId) {
		this.objectId = objectId;
	}


	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}


	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}


	/**
	 * @return the summary
	 */
	public String getSummary() {
		return summary;
	}


	/**
	 * @param summary the summary to set
	 */
	public void setSummary(String summary) {
		this.summary = summary;
	}


	/**
	 * @return the authors
	 */
	public Set<Author> getAuthors() {
		return authors;
	}


	/**
	 * @param authors the authors to set
	 */
	public void setAuthors(Set<Author> authors) {
		this.authors = authors;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
